<template>
  <view class="new-arrival-section">
    <view class="section-header">
      <text class="section-title">{{ title }}</text>
      <view class="view-more" @click="onViewMore">
        <text>查看更多</text>
        <uni-icons type="right" size="14" color="#999"></uni-icons>
      </view>
    </view>
    
    <view class="product-list">
      <view 
        class="product-item" 
        v-for="(item, index) in products" 
        :key="index"
        @click="onItemClick(item)"
      >
        <image :src="item.image" mode="aspectFill" class="product-image"></image>
        <view class="product-info">
          <text class="product-name">{{ item.name }}</text>
          <view class="new-tag">新品</view>
          <view class="product-price">
            <text class="price">¥{{ item.price }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'NewArrivalSection',
  props: {
    title: {
      type: String,
      default: '新品上市'
    },
    products: {
      type: Array,
      default: () => []
    },
    moreUrl: {
      type: String,
      default: ''
    }
  },
  methods: {
    onViewMore() {
      this.$emit('view-more')
    },
    onItemClick(item) {
      this.$emit('item-click', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.new-arrival-section {
  background-color: #ffffff;
  border-radius: 12rpx;
  margin: 20rpx;
  padding: 20rpx;
  
  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20rpx;
    
    .section-title {
      font-size: 32rpx;
      font-weight: bold;
      color: #333;
      position: relative;
      padding-left: 20rpx;
      
      &::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 6rpx;
        height: 30rpx;
        background-color: #ff5500;
        border-radius: 3rpx;
      }
    }
    
    .view-more {
      display: flex;
      align-items: center;
      
      text {
        font-size: 24rpx;
        color: #999;
        margin-right: 4rpx;
      }
    }
  }
  
  .product-list {
    display: flex;
    flex-direction: column;
    
    .product-item {
      display: flex;
      margin-bottom: 20rpx;
      background-color: #f8f8f8;
      border-radius: 8rpx;
      padding: 10rpx;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      .product-image {
        width: 180rpx;
        height: 180rpx;
        border-radius: 8rpx;
        margin-right: 20rpx;
      }
      
      .product-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        position: relative;
        
        .product-name {
          font-size: 28rpx;
          color: #333;
          @include multi-ellipsis(2);
          margin-right: 60rpx;
        }
        
        .new-tag {
          position: absolute;
          top: 0;
          right: 0;
          background-color: #ff5500;
          color: #fff;
          font-size: 20rpx;
          padding: 4rpx 10rpx;
          border-radius: 20rpx;
        }
        
        .product-price {
          .price {
            font-size: 32rpx;
            color: #ff5500;
            font-weight: bold;
          }
        }
      }
    }
  }
}
</style> 